<html xmlns="http://www.w3.org/1999/xhtml" xmlns:c="http://java.sun.com/jstl/core"
      xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:t="http://myfaces.apache.org/tomahawk">

    <f:view>
        <f:loadBundle var="text" basename="#{exchangeRateList.bundleName}"/>
        <head>
            <title>#{text['exchangeRateList.title']}</title>
            <meta name="heading" content="#{text['exchangeRateList.heading']}"/>
            <meta name="menu" content="CatalogsMenu"/>
        </head>
        <body id="exchangeRateList">
        <h:form id="editexchangeRate">

            <h:commandButton value="#{text['button.search']}"  action="#{exchangeRateList.execute}" id="search" styleClass="button" style="margin-left: 5px"/>
            <h:commandButton value="#{text['button.add']}" action="add" id="add" immediate="true" styleClass="button"/>
            <h:commandButton value="#{text['button.done']}" action="mainMenu" id="cancel" immediate="true" styleClass="button"/>            

            <h:panelGroup>
                <table>
                    <tr>
                        <td>
                    <t:htmlTag value="div">
                        <h:outputLabel styleClass="desc" for="date" value="#{text['exchangeRate.date']}"/>
                        <t:inputCalendar id="date" value="#{exchangeRateList.date}" renderAsPopup="true"
                                         popupDateFormat="dd/MM/yyyy" popupTodayString="Hoy es "
                                         popupWeekString="Semana" lang="es">
                        </t:inputCalendar>
                        <t:message for="date" styleClass="fieldError"/>
                    </t:htmlTag>
                    </td>
                    <td>
                    <t:htmlTag value="div">
                        <h:outputLabel styleClass="desc" for="type" value="#{text['exchangeRate.type']}"/>
                        <h:selectOneMenu value="#{exchangeRateList.stType}" id="type" styleClass="select">
                            <f:selectItem itemLabel="Todos"/>
                            <f:selectItem itemLabel="DIARIA" itemValue="DIARIA"/>
                            <f:selectItem itemLabel="MENSUAL" itemValue="MENSUAL"/>
                            <f:selectItem itemLabel="ANUAL" itemValue="ANUAL"/>
                        </h:selectOneMenu>
                        <t:message for="type" styleClass="fieldError"/>
                    </t:htmlTag>
                    </td>
                    </tr>
                    <tr>
                        <!--td>
                    <t:htmlTag value="div">
                        <h:outputLabel styleClass="desc" for="fromCurrency" value="#{text['exchangeRate.fromCurrency']}"/>
                        <h:selectOneMenu value="#{exchangeRateList.fromCurrency}" id="fromCurrency" styleClass="select">
                            <f:selectItem itemLabel="Todas"/>
                            <t:selectItems value="#{exchangeRateList.currencies}" var="currency" itemLabel="#{currency.description}" itemValue="#{currency}"/>
                            <f:converter converterId="objconverter"/>
                        </h:selectOneMenu>
                        <t:message for="fromCurrency" styleClass="fieldError"/>
                    </t:htmlTag>
                    </td-->
                    <td>
                    <t:htmlTag value="div">
                        <h:outputLabel styleClass="desc" for="toCurrency" value="#{text['exchangeRate.toCurrency']}"/>
                        <h:selectOneMenu value="#{exchangeRateList.toCurrency}" id="toCurrency" styleClass="select">
                            <f:selectItem itemLabel="Todas"/>
                            <t:selectItems value="#{exchangeRateList.currencies}" var="currency" itemLabel="#{currency.description}" itemValue="#{currency}"/>
                            <f:converter converterId="objconverter"/>
                        </h:selectOneMenu>
                        <t:message for="toCurrency" styleClass="fieldError"/>
                    </t:htmlTag>
                    </td>
                    </tr>
                </table>
            </h:panelGroup>
            <!-- Error from this table is caused by http://issues.apache.org/jira/browse/TOMAHAWK-466 -->
            <t:dataTable id="exchangeRates" var="exchangeRate" style="margin-top: 10px"
                         value="#{exchangeRateList.exchangeRates}" rows="25" sortColumn="#{exchangeRateList.sortColumn}"
                         sortAscending="#{exchangeRateList.ascending}" styleClass="scrollerTable table"
                         headerClass="standardTable_Header" rowClasses="standardTable_Row1,standardTable_Row2"
                         columnClasses="standardTable_Column,standardTable_Column,standardTable_Column,standardTable_Column,standardTable_ColumnCentered">
                <t:column>
                    <f:facet name="header">
                        <t:commandSortHeader columnName="id" arrow="true">
                            <h:outputText value="#{text['exchangeRate.id']}" />
                        </t:commandSortHeader>
                    </f:facet>
                    <h:commandLink action="#{exchangeRateForm.edit}" value="#{exchangeRate.id}">
                        <f:param name="id" value="#{exchangeRate.id}"/>
                        <f:param name="from" value="list"/>
                    </h:commandLink>
                </t:column>

                <t:column>
                    <f:facet name="header">
                        <t:commandSortHeader columnName="date" arrow="true">
                            <h:outputText value="#{text['exchangeRate.date']}" />
                        </t:commandSortHeader>
                    </f:facet>
                    <h:outputText value="#{exchangeRate.date}" escape="true">
                        <f:convertDateTime pattern="dd/MM/yyyy"/>
                    </h:outputText>
                </t:column>

                <t:column>
                    <f:facet name="header">
                        <t:commandSortHeader columnName="fromCurrency" arrow="true">
                            <h:outputText value="#{text['exchangeRate.fromCurrency']}" />
                        </t:commandSortHeader>
                    </f:facet>
                    <h:outputText value="#{exchangeRate.fromCurrency.symbol}" escape="true"/>
                </t:column>

                <t:column>
                    <f:facet name="header">
                        <t:commandSortHeader columnName="toCurrency" arrow="true">
                            <h:outputText value="#{text['exchangeRate.toCurrency']}" />
                        </t:commandSortHeader>
                    </f:facet>
                    <h:outputText value="#{exchangeRate.toCurrency.symbol}" escape="true"/>
                </t:column>

                <t:column>
                    <f:facet name="header">
                        <t:commandSortHeader columnName="rate" arrow="true">
                            <h:outputText value="#{text['exchangeRate.rate']}" />
                        </t:commandSortHeader>
                    </f:facet>
                    <h:outputText value="#{exchangeRate.rate}" escape="true"/>
                </t:column>

                <t:column>
                    <f:facet name="header">
                        <t:commandSortHeader columnName="type" arrow="true">
                            <h:outputText value="#{text['exchangeRate.type']}" />
                        </t:commandSortHeader>
                    </f:facet>
                    <h:outputText value="#{exchangeRate.type}" escape="true"/>
                </t:column>
            </t:dataTable>

            <t:saveState id="save1" value="#{exchangeRateList.exchangeRates}"/>

            <ui:include src="/common/tableFooter.xhtml">
                <ui:param name="tableName" value="exchangeRates"/>
            </ui:include>

            <script type="text/javascript">
                highlightTableRows("editexchangeRate:exchangeRates");
            </script>

        </h:form>
    </body>
</f:view>
</html>